package babo.cd.physicalexperiment.adapter;



import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;

import java.util.ArrayList;
import java.util.List;


public class MyPagerAdapter extends FragmentStatePagerAdapter {
    private List<String> list;
    private ArrayList<Fragment> viewPagerFragments;

    public MyPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    public void setTitles( List<String> list) {
        if(this.list != null) {
            this.list.clear();
        }
        this.list = list;
    }

    public void setFragments(ArrayList<Fragment> viewPagerFragments) {
        this.viewPagerFragments = viewPagerFragments;
    }

    @Override
    public Fragment getItem(int position) {
        return viewPagerFragments.get(position);
    }

    @Override
    public int getCount() {
        return viewPagerFragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return list.get(position);
    }
}
